home *** CD-ROM | disk | FTP | other *** search
- package sun.awt.im;
-
- import java.awt.AWTEvent;
- import java.awt.Component;
- import java.awt.Toolkit;
- import java.util.EventObject;
- import sun.awt.SunToolkit;
-
- public class InputContext {
- private InputMethod inputMethod;
- private boolean inputMethodCreationFailed;
- private Component currentClientComponent;
-
- protected InputContext() {
- }
-
- public static InputContext getInstance() {
- return new InputMethodContext();
- }
-
- public synchronized void dispatchEvent(AWTEvent var1) {
- InputMethod var2 = this.getInputMethod();
- int var3 = var1.getID();
- switch (var3) {
- case 103:
- this.dispose();
- this.currentClientComponent = null;
- return;
- case 1004:
- this.activate((Component)((EventObject)var1).getSource());
- if (var2 != null) {
- var2.dispatchEvent(var1);
- return;
- }
- break;
- case 1005:
- if (var2 != null) {
- var2.dispatchEvent(var1);
- }
-
- this.deactivate((Component)((EventObject)var1).getSource());
- return;
- default:
- if (var2 != null) {
- var2.dispatchEvent(var1);
- }
- }
-
- }
-
- synchronized void activate(Component var1) {
- this.currentClientComponent = var1;
- if (this.inputMethod != null) {
- if (this.inputMethod instanceof InputMethodAdapter) {
- ((InputMethodAdapter)this.inputMethod).setClientComponent(var1);
- }
-
- this.inputMethod.activate();
- }
-
- }
-
- synchronized void deactivate(Component var1) {
- if (this.inputMethod != null) {
- this.inputMethod.deactivate();
- }
-
- this.currentClientComponent = null;
- }
-
- Component getClientComponent() {
- Component var1 = this.currentClientComponent;
- return var1;
- }
-
- public void dispose() {
- if (this.inputMethod != null) {
- this.inputMethod.dispose();
- this.inputMethod = null;
- }
-
- }
-
- InputMethod getInputMethod() {
- if (this.inputMethod != null) {
- return this.inputMethod;
- } else if (this.inputMethodCreationFailed) {
- return null;
- } else {
- try {
- Toolkit var1 = Toolkit.getDefaultToolkit();
- this.inputMethod = ((SunToolkit)var1).getInputMethodAdapter();
- } catch (Exception var2) {
- this.inputMethodCreationFailed = true;
- }
-
- if (this.inputMethod != null) {
- this.inputMethod.setInputContext((InputMethodContext)this);
- }
-
- return this.inputMethod;
- }
- }
- }
-